export const slideBanner = function (comp) {
  //选中item的盒子
  let box = comp.vnode.el;
  // document.querySelector(".el-carousel__container");
  //手指起点X坐标
  let startPoint = 0;
  //手指滑动重点X坐标
  let stopPoint = 0;

  //重置坐标
  let resetPoint = function () {
    startPoint = 0;
    stopPoint = 0;
  };

  //手指按下
  box.addEventListener("touchstart", function (e) {
    //手指点击位置的X坐标
    startPoint = e.changedTouches[0].pageX;
  });
  //手指滑动
  box.addEventListener("touchmove", function (e) {
    //手指滑动后终点位置X的坐标
    stopPoint = e.changedTouches[0].pageX;
  });
  //当手指抬起的时候，判断图片滚动离左右的距离
  box.addEventListener("touchend", function (e) {
    if (stopPoint == 0 || startPoint - stopPoint == 0) {
      resetPoint();
      return;
    }
    if (startPoint - stopPoint > 0) {
      resetPoint();
      comp.refs["carousel"].next();
      return;
    }
    if (startPoint - stopPoint < 0) {
      resetPoint();
      comp.refs["carousel"].prev();
      return;
    }
  });
};
